package com.u.social.recommend.service.articles;

import com.alibaba.fastjson.JSON;
import com.u.social.recommend.model.ArticleDTO;
import com.u.social.recommend.model.UserDTO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: u-social
 * @description: AI能力远程调用逻辑类
 * @author: Alex Wu
 * @createDate: 2025-04-07 16:39
 **/

@Service
public class AIApiService {

    /**
     * 将用户信息转换为向量
     *
     * @param userInfo 用户信息
     * @param isDisturbing 是否打扰
     * @return 向量
     */
    public List<String> transformEmbedding(String userInfo, Boolean isDisturbing) {
        UserDTO userDTO = JSON.parseObject(userInfo, UserDTO.class);
        // 归一化, 将用户信息转换为向量
        List<String> vector = new ArrayList<>();
        if(userDTO.getId() > 10){
            vector.add("0.5");
        }
        else{
            vector.add("0.1");
        }

        if(isDisturbing){
            vector.add("0.001");
        }
        return vector;
    }

    public List<String> generalRankFeatures(List<ArticleDTO> articlesDTOs, List<String> userFeatures) {
        System.out.println("调用AI能力构建总特征");
        return new ArrayList<String>();
    }

    public List<Float> predictRanking(List<String> features) {
        System.out.println("调用AI能力进行打分");
        return new ArrayList<Float>();
    }




}
